<include file="Layout/header" />
<body>
<div class="breadcrumbs" id="breadcrumbs"> 
  <script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>
  <ul class="breadcrumb">
    <li> <i class="icon-home home-icon"></i> <a href="{:U('Admin/Index/welcome')}">首页</a> </li>
    <li class="active">文章分类</li>
  </ul>
</div>
<div class="page-content">
  <div class="page-header">
    <h1> 文章分类 <small> <i class="icon-double-angle-right"></i> 文章分类 </small> </h1>
  </div>
  <div class="row">
    <form method="post" action="{:U('Admin/Article/cat')}">
      <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
           <td width="15%"><input class="col-xs-12 col-sm-8" type="text" name="ac_name" placeholder="分类名称"></td>
          
          <td width="20%"><input class="btn btn-success" type="submit" value="搜索"></td>
        </tr>
      </table>
    </form>
    <div class="col-xs-12">
    <a class="btn btn-primary" href="{:U('Admin/Article/article_cat_add')}" style="margin-bottom: 5px;"><i class="icon-plus align-top bigger-125"></i>新增分类</a>
      <div class="table-responsive">
        <table id="example-advanced" class="table table-striped table-bordered table-hover">
          <thead>
            <tr>
             <th class="center"> <label>
                  <input class="ace" type="checkbox">
                  <span class="lbl"></span> </label>
              </th>
              <th>排序</th>
              <th>分类名称</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
          <form method="post" action="{:U('Admin/Article/detadelclass')}" id="ondel">
           <foreach name="parent_list" item="val">
               <tr data-tt-id="{$val.ac_id}">
                <td class="center"><label>
                    <input class="ace" type="checkbox" value="{$val.ac_id}" name="ac_id[]">
                    <span class="lbl"></span> </label></td>
                <td>
                <div class="col-sm-4">
					<input id="{$val.ac_id}" class="col-xs-10 col-sm-5" type="text" value="{$val.ac_sort}"  onblur="onblus({$val.ac_id})">
				</div>
                </td> 
                <td class="hidden-480">
                <div class="col-sm-8">
					<input id="n_{$val.ac_id}" class="col-xs-10 col-sm-8" type="text" value="{$val.ac_name}" onBlur="onblus_name({$val.ac_id})">
				</div></td>
                
                 
                <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                <a class="btn btn-xs btn-info" href="{:U('Admin/Article/article_cat_edit')}/id/{$val.ac_id}"> <i class="icon-edit bigger-120"></i> </a> 
                <a class="btn btn-xs btn-danger" onClick="article_del(this,{$val.ac_id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
              </tr>
              
              <foreach name="val.parent" item="v">
              <tr data-tt-id="t-{$v.ac_parent_id}" data-tt-parent-id="{$v.ac_parent_id}">
                 <td class="center"><label>
                    <input class="ace" type="checkbox" value="{$v.ac_id}" name="ac_id[]">
                    <span class="lbl"></span> </label></td>
                <td>
                <div class="col-sm-4">
					<input id="{$v.ac_id}" class="col-xs-10 col-sm-5" type="text" value="{$v.ac_sort}"  onblur="onblus({$v.ac_id})" style="left: 40px;">
				</div>
                </td>
                 <td class="hidden-480">
                 <div class="col-sm-8">
					<input id="n_{$v.ac_id}" class="col-xs-10 col-sm-8" type="text" value="{$v.ac_name}" onBlur="onblus_name({$v.ac_id})">
				</div>
                 </td>
                 <td><div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
                     <a class="btn btn-xs btn-info" href="{:U('Admin/Article/article_cat_edit')}/id/{$v.ac_id}"> <i class="icon-edit bigger-120"></i> </a> 
                     <a class="btn btn-xs btn-danger" onClick="article_del(this,{$v.ac_id})"> <i class="icon-trash bigger-120"></i> </a> </div></td>
              </tr>
              </foreach>
              </foreach>
          </form>
            </tbody>
          
        </table>
        <div>
          <button class="btn btn-danger" onClick="datadel()">批量删除</button>
        </div>
      </div>
      <input type="hidden" value="{:U('Admin/Article/edit_cat_sort')}" id="change_sort">
      <input type="hidden" value="{:U('Admin/Article/edit_cat_name')}" id="change_name">
      <input type="hidden" value="{:U('Admin/Article/articleclass_del')}" id="del_cat">
      <!-- /.table-responsive --> 
    </div>
    <div >{$article.page}</div>
  </div>
</div>
<include file="Layout/js"/> 
 <link rel="stylesheet" href="__ADMIN_CSS__/jquery.treetable.css" />
 <script src="__ADMIN_JS__/jquery.treetable.js"></script>
 <script src="__ADMIN_JS__/jquery.dataTables.min.js"></script> 
<script src="__ADMIN_JS__/jquery.dataTables.bootstrap.js"></script> 
<script src="__ADMIN_JS__/bootbox.js"></script> 
<script type="text/javascript">
			jQuery(function($) {
 				$("#example-advanced").treetable({  
                   expandable : true  ,
				  column:1
            }); 
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
  				
			})
 		</script> 
<script type="text/javascript">       
 function onblus(ac_id){
    var ac_id=ac_id;
	var ac_sort=$("#"+ac_id+"").val();
	 
	var host= $("#change_sort").val();
    $.post(host,{ac_id :ac_id,ac_sort:ac_sort},function (data){
 	 
	    if(data.status==0){
 		bootbox.alert(data.info);	
		}
	 
	   });
	 
}
function onblus_name(ac_id){
    var ac_id=ac_id;
	var ac_name=$("#n_"+ac_id+"").val();
	 
	
	var host=$("#change_name").val();
    $.post(host,{ac_id :ac_id,ac_name:ac_name},function (data){
		 if(data.status==0){
 		bootbox.alert(data.info);	
		 }
 	   });
	 
}
     /* 删除*/
function article_del(obj,id){
	   var host= $("#del_cat").val();
      bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该分类?", function(result) {  
        if (result) {  
           $.ajax({
			 url:host,
			type:"POST",
			dataType:"json",
			data:{ac_id:id},
			success: function(data){
 				if(data.status==0){
 				bootbox.alert(data.info);	
					}else{
				$(obj).parents("tr").remove();		
						}
				}
			})
		
		 
        }  
      });  
 
}
/*批量-删除*/
function datadel(){
	  var is_check=$("input[type='checkbox']").is(':checked');
    if(is_check){
	    bootbox.setLocale("zh_CN");  
      bootbox.confirm("确定删除该分类?", function(result) {  
        if (result) {  
           $("#ondel").submit();
         }  
      }); 
    }else{
      bootbox.alert({  
            buttons: {  
               ok: {  
                    label: '返回',  
                    className: 'btn-myStyle'  
                }  
            },  
            message: '请选择要删除的分类',  
            callback: function() {  
               // alert('关闭了alert');  
            },  
            title: "提示信息",  
        });
    } 
	 
	
}
 </script>
</body>
</html>